package gameobjects;

import javagame.Level;

import org.newdawn.slick.Animation;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

public class Top extends Protivnik {
	
	//POLJA KLASE
	private static int startHP = 2;
	
	private Image HP_bar;//bar za prikazivanje preostale snage
	
	//KONSTRUKTOR
	
	public Top(Igrac igrac, Igrac2 igrac2, Level nivo) {
		super(igrac,igrac2, nivo);
		this.setHP(startHP);
		this.setVrsta(tip_protivnika.TOP);
		this.setSizeX(50);
		this.setSizeY(50);
		this.setBrojTopova(1);
		this.dodajTop(0, 23, 50, 23, 0, 50, 24, 0, 24);
	}
	
	//GET I SET METODE
	
	public Image getHP_bar() {
		return HP_bar;
	}

	public void setHP_bar(Image hPBar) {
		HP_bar = hPBar;
	}
	
	//CRTANJE
	
	//postavljanje animacije
	public void setAnimation() throws SlickException {
		Image [] up = {new Image("res/top_gore.png"), new Image("res/top_gore.png")};
		Image [] down = {new Image("res/top_dole.png"), new Image("res/top_dole.png")};
		Image [] left = {new Image("res/top_levo.png"), new Image("res/top_levo.png")};
		Image [] right = {new Image("res/top_desno.png"), new Image("res/top_desno.png")};
		this.setMovingUp(new Animation(up, this.getDuration(), true));//true se stavlja zbog autoupdate
		this.setMovingDown(new Animation(down, this.getDuration(), true));
		this.setMovingLeft(new Animation(left, this.getDuration(), true));
		this.setMovingRight(new Animation(right, this.getDuration(), true));
		this.setProtivnik(this.getMovingDown());
	}
	
	//iscrtavanje tenka i health bara
	public void crtaj(Graphics g) throws SlickException {
		super.crtaj(g);
		
		Color stara = g.getColor();
		g.setColor(Igrac.DARK_RED);
		g.fillRect(getProtivnikX(), getProtivnikY()-20, 50, 10);
		g.setColor(Igrac.LIME);
		g.fillRect(getProtivnikX(), getProtivnikY()-20, 50*getHP()/startHP, 10);
		g.setColor(Color.black);
		g.drawRect(getProtivnikX(), getProtivnikY()-20, 50, 10);
		g.setColor(stara);
	}
	
	//AI PROTIVNIKA
	
	public void  protivnikAI(int delta, Kolizija kolizija, boolean belo)  throws SlickException {
		if(this.isUbiven() == false) fire(belo);
	}
	
	public void ozivi() {
		super.ozivi();
		this.setHP(startHP);
	}

}
